#include <stdio.h>

int is_leapYear(int year);

int main() {
	int input_year = 0, input_month = 0;
	int month[12] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};

	scanf("%d %d", &input_year, &input_month);
	if (is_leapYear(input_year) && input_month == 2) {
		printf("29");
	} else {
		printf("%d", month[input_month - 1]);
	}

	return 0;
}

int is_leapYear(int year) {
	if (year % 4 == 0 && year % 100 != 0 || year % 400 == 0) {
		return 1;
	} else {
		return 0;
	}
}